<template>
	<!-- 顶部导航栏 -->
	<view>
		<view class="header-section">
			<uni-icons type="back" size="30" @click="goBack"></uni-icons>
			<view class="title">地图</view>
			<uni-icons type="search" size="30" @click="goSearch"></uni-icons>
		</view>
		<view class="page-main">
			<liu-easy-map ref="liuEasyMap" :centerLat="'24.626898'" :centerLng="'118.091247'" :scale="14"
				:markerData="markerData" @clickMarker="markerClick"></liu-easy-map>
		</view>
	</view>

</template>

<script>
	import {
		getAllShop
	} from '../../api/shop';
	export default {
		data() {
			return {
				addressInfo: {
					id: 1,
					name: '', //标记点展示名字
					address: '',
					latitude: '', //标记点纬度
					longitude: '', //标记点经度
					iconWidth: 32, //标记点图标宽度
					iconHeight: 32, //标记点图标高度
					calloutColor: '#ffffff', //气泡窗口 文本颜色
					calloutFontSize: 14, //气泡窗口 文本大小
					calloutBorderRadius: 6, //气泡窗口 边框圆角
					calloutPadding: 8, //气泡窗口 文本边缘留白
					calloutBgColor: '#ffcbb2', //气泡窗口 背景颜色
					calloutDisplay: 'ALWAYS', //气泡窗口 展示类型 默认常显 'ALWAYS' 常显 'BYCLICK' 点击显示
				},
				markerData: [],
			}
		},
		created() {
			this.markerData=[];
			this.getAllShopInfo();
		},
		methods: {
			//点击标记点
			markerClick(e) {
				console.log('点击标记点信息：', e)
			},
			goBack() {
				uni.navigateBack();
			},
			goSearch() {
				uni.navigateTo({
					url: '/pages/search/search'
				});
			},
			getAllShopInfo() {
				getAllShop().then(res => {
					res.data.forEach(item => {
						this.addressInfo.id = item.storeId;
						this.addressInfo.name = item.storeName;
						this.addressInfo.address = item.storeAddress;
						this.addressInfo.latitude = item.storeLatitude;
						this.addressInfo.longitude = item.storeLongitude;
						console.log(this.addressInfo);
						this.markerData.push(this.addressInfo);
						this.addressInfo={};
					});
				})
			}
		}
	}
</script>

<style lang="scss">
	.page-main {
		width: 100%;
		height: 100vh;
	}

	.header-section {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 10px;
		background-color: #ffffff;
		position: fixed;
		top: 0;
		width: 100%;
		box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
		z-index: 10;
	}

	.title {
		font-size: 18px;
		font-weight: bold;
	}
</style>